package org.chaiyi.template.app.demo;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.UUID;

@RestController
@Tag(name = "注解测试接口") //看这里
@RequestMapping("test/annotation")
public class AnnotationDemoApi {

    @PostMapping
    @Operation(summary = "假如这是一个插入方法") //看这里
    public Flux<DemoResponseBody> insert(@RequestBody DemoRequestBody requestBody) {
        return Flux.just(new DemoResponseBody(UUID.randomUUID().toString(), requestBody.getName(), requestBody.getAge()));
    }

    @Data
    @Schema(title = "这是一个请求体Schema")//看这里
    public static class DemoRequestBody {
        @Schema(title = "姓名")//看这里
        private String name;
        @Schema(title = "年龄")
        private Integer age;
    }

    @Getter
    @AllArgsConstructor
    @Schema(title = "这是一个响应体Schema")
    public static class DemoResponseBody {
        private String id;
        private String name;
        private Integer age;
    }
}
